package com.lzb.service;

import javax.annotation.Resource;

import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.lzb.domain.Article;
import com.lzb.mapper.ArticleMapper;

@Service(ArticleService.BEAN_PACKAGE_NAME)
@Transactional(readOnly=true)
public class ArticleService {

	public static final String BEAN_PACKAGE_NAME = "com.lzb.service.ArticleService";
	
	@Resource(name = "sqlSession")
	private SqlSession sqlSession;
	
	@Transactional(isolation=Isolation.DEFAULT,propagation=Propagation.REQUIRED,readOnly=false)
	public void add(Article article) {
		try {
			ArticleMapper articleMapper = sqlSession.getMapper(ArticleMapper.class);
			articleMapper.insert(article);
		} catch(Exception e) {
			e.printStackTrace();
		}
	}
}
